package com.zzw.thread;

public class Money {

	private ThreadLocal<String> name = new ThreadLocal<>();
	
	public Money(String str){
		this.name.set(str);
	}
	
	public String getName() {
		return name.get();
	}
	
	public void setName(String str) {
		this.name.set(str);
	}
	public static void main(String[] args) {
		Money money = new Money("");
		new MyTest(money, "").start();
		new MyTest(money, "").start();
	}
}

class MyTest extends Thread{

	private Money money;
	public MyTest(Money money,String name){
		super(name);
		this.money = money;
	}
	
	public void run(){
		for(int i = 0;i < 10;i++){
			if(i == 6){
				money.setName(getName());
			}
			System.out.println(money.getName() + "" + i);
		}
	}
}